package com.ruoyi.project.data.proc.controller;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.project.data.proc.domain.DsTrDateProcState;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.data.proc.service.IDsTrDateProcStateService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import java.util.Arrays;

import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 交易日处理查询Controller
 *
 * @author 魏刚
 * @date 2020-03-15
 */
@Controller
@RequestMapping("/data/proc")
public class DsTrDateProcStateController extends BaseController
{
    private String prefix = "data/proc";

    @Autowired
    private IDsTrDateProcStateService dsTrDateProcStateService;

    @RequiresPermissions("data:proc:view")
    @GetMapping()
    public String proc()
    {
        return prefix + "/proc";
    }

    /**
     * 查询交易日处理查询列表
     */
    @RequiresPermissions("data:proc:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DsTrDateProcState dsTrDateProcState)
    {
        startPage();
        List<DsTrDateProcState> list = dsTrDateProcStateService.list(new QueryWrapper<DsTrDateProcState>(dsTrDateProcState).orderByDesc("tr_date"));
        return getDataTable(list);
    }

    /**
     * 导出交易日处理查询列表
     */
    @RequiresPermissions("data:proc:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(DsTrDateProcState dsTrDateProcState)
    {
        List<DsTrDateProcState> list = dsTrDateProcStateService.list(new QueryWrapper<DsTrDateProcState>(dsTrDateProcState));
        ExcelUtil<DsTrDateProcState> util = new ExcelUtil<DsTrDateProcState>(DsTrDateProcState.class);
        return util.exportExcel(list, "proc");
    }

    /**
     * 新增交易日处理查询
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存交易日处理查询
     */
    @RequiresPermissions("data:proc:add")
    @Log(title = "交易日处理查询", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DsTrDateProcState dsTrDateProcState)
    {
        return toAjax(dsTrDateProcStateService.saveOrUpdate(dsTrDateProcState));
    }

    /**
     * 修改交易日处理查询
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        DsTrDateProcState dsTrDateProcState = dsTrDateProcStateService.getById(id);
        mmap.put("dsTrDateProcState", dsTrDateProcState);
        return prefix + "/edit";
    }

    /**
     * 修改保存交易日处理查询
     */
    @RequiresPermissions("data:proc:edit")
    @Log(title = "交易日处理查询", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DsTrDateProcState dsTrDateProcState)
    {
        return toAjax(dsTrDateProcStateService.saveOrUpdate(dsTrDateProcState));
    }

    /**
     * 删除交易日处理查询
     */
    @RequiresPermissions("data:proc:remove")
    @Log(title = "交易日处理查询", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(dsTrDateProcStateService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
